package com.chat.api.common.exception;
/**
 * @author peidx
 * @since 20181213
 * **/
public class ApiException extends RuntimeException {
	private static final long serialVersionUID = -8880499705725759825L;

	private Integer code;

	/** 异常消息  */
    private String errorMessage;
    
    /** 跳转路径 */
    private String errorUrl;

    public ApiException(Integer code, String errorMessage, String errorUrl) {
    	super(errorMessage);
        this.code = code;
        this.errorMessage = errorMessage;
        this.setErrorUrl(errorUrl);
    }
    
    public ApiException(String errorMessage) {
    	this(CoreExceptionEnum.E_SYS.getCode(), errorMessage, "");
    }
    
    public ApiException(Integer code, String errorMessage) {
    	super(errorMessage);
        this.code = code;
        this.errorMessage = errorMessage;
        this.errorUrl="";
    }

    public ApiException(AbstractBaseExceptionEnum exception, String errorUrl) {
    	super(exception.getMessage());
        this.code = exception.getCode();
        this.errorMessage = exception.getMessage();
        this.errorUrl=errorUrl;
    }
    
    public ApiException(AbstractBaseExceptionEnum exception) {
    	super(exception.getMessage());
        this.code = exception.getCode();
        this.errorMessage = exception.getMessage();
        this.errorUrl="";
    }

    public ApiException() {
		super();
	}

	public ApiException(Throwable ex) {
		super(ex);
	}

	public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

	public String getErrorUrl() {
		return errorUrl;
	}

	public void setErrorUrl(String errorUrl) {
		this.errorUrl = errorUrl;
	}
}
